home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3 / impCreateZoom.z / impCreateZoom
Encoding:
Text File  |  2002-10-03  |  16.1 KB  |  331 lines

  1.  
  2.  
  3.  
  4. iiiimmmmppppZZZZoooooooommmmRRRRoooowwww((((3333))))                    IIIImmmmpppprrrreeeessssssssaaaarrrriiiioooo                     iiiimmmmppppZZZZoooooooommmmRRRRoooowwww((((3333))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      impCreateZoom, impDestroyZoom, impResetZoom, impZoomRow - zoom image data
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.      ####iiiinnnncccclllluuuuddddeeee <<<<iiiimmmmpppp....hhhh>>>>
  13.  
  14.      IIIIMMMMPPPPZZZZoooooooommmm**** iiiimmmmppppCCCCrrrreeeeaaaatttteeeeZZZZoooooooommmm((((uuuusssshhhhoooorrrrtttt____tttt ssssrrrrccccXXXXSSSSiiiizzzzeeee,,,, uuuusssshhhhoooorrrrtttt____tttt ssssrrrrccccYYYYSSSSiiiizzzzeeee,,,,
  15.                             uuuusssshhhhoooorrrrtttt____tttt ddddssssttttXXXXSSSSiiiizzzzeeee,,,, uuuusssshhhhoooorrrrtttt____tttt ddddssssttttYYYYSSSSiiiizzzzeeee,,,,
  16.                             lllloooonnnngggg mmmmiiiinnnn,,,, lllloooonnnngggg mmmmaaaaxxxx,,,,
  17.                             IIIIMMMMPPPPRRRReeeeaaaaddddRRRRoooowwwwFFFFuuuunnnncccc rrrreeeeaaaaddddRRRRoooowwwwFFFFuuuunnnncccc,,,,
  18.                             iiiinnnntttt nnnnuuuummmmCCCChhhhaaaannnnnnnneeeellllssss,,,,
  19.                             IIIIMMMMPPPPFFFFiiiilllltttteeeerrrrTTTTyyyyppppeeee ffffiiiilllltttteeeerrrrTTTTyyyyppppeeee,,,,
  20.                             ffffllllooooaaaatttt bbbblllluuuurrrrFFFFaaaaccccttttoooorrrr))));;;;
  21.  
  22.      vvvvooooiiiidddd iiiimmmmppppDDDDeeeessssttttrrrrooooyyyyZZZZoooooooommmm((((IIIIMMMMPPPPZZZZoooooooommmm ****zzzzoooooooommmm))));;;;
  23.  
  24.      vvvvooooiiiidddd iiiimmmmppppRRRReeeesssseeeettttZZZZoooooooommmm((((IIIIMMMMPPPPZZZZoooooooommmm ****zzzzoooooooommmm))));;;;
  25.  
  26.      iiiinnnntttt iiiimmmmppppZZZZoooooooommmmRRRRoooowwww((((IIIIMMMMPPPPZZZZoooooooommmm ****zzzzoooooooommmm,,,, sssshhhhoooorrrrtttt ****bbbbuuuuffffffffeeeerrrr,,,,
  27.                     uuuusssshhhhoooorrrrtttt____tttt rrrroooowwww,,,, vvvvooooiiiidddd ****cccclllliiiieeeennnnttttDDDDaaaattttaaaa))));;;;
  28.  
  29. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  30.      The _l_i_b_i_m_p library provides an API for performing image resizing or
  31.      zooming. Images can be zoomed up or down using any of a number of
  32.      resampling methods. The resampling methods divide into two categories.
  33.      The first resampling category is non-filtered zooming (a.k.a. replicative
  34.      zoom, decimation). The second resampling category is filtered zooming
  35.      where a filter of a given shape is applied to the data.  The image
  36.      zooming is performed on a row by row basis using a one pass, two
  37.      dimensional convolution.
  38.  
  39.      To zoom one or more rows of an image, first create a zoom operator by
  40.      calling _i_m_p_C_r_e_a_t_e_Z_o_o_m. One of the parameters to _i_m_p_C_r_e_a_t_e_Z_o_o_m is a
  41.      pointer to a function that will be called during the zoom to read rows of
  42.      the source image. To obtain zoomed rows call _i_m_p_Z_o_o_m_R_o_w.  When all
  43.      desired zoomed rows have been obtained, call _i_m_p_D_e_s_t_r_o_y_Z_o_o_m to deallocate
  44.      storage held by the zoom operator.
  45.  
  46.      When filtered zooming is performed a number of contiguous rows of image
  47.      data are cached. Often all rows of a given image channel are zoomed
  48.      followed by all rows of the next channel. Since rows are cached, the
  49.      cache should be flushed when switching between image channels. The
  50.      _i_m_p_R_e_s_e_t_Z_o_o_m function performs this row cache flushing operation.
  51.  
  52.      The _i_m_p_C_r_e_a_t_e_Z_o_o_m function has the following parameters:
  53.  
  54.      _s_r_c_X_S_i_z_e, _s_r_c_Y_S_i_z_e
  55.                     Width and height of the source image in pixels.
  56.  
  57.      _d_s_t_X_S_i_z_e, _d_s_t_Y_S_i_z_e
  58.                     Width and height of the destination (i.e. zoomed) image in
  59.                     pixels.
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. iiiimmmmppppZZZZoooooooommmmRRRRoooowwww((((3333))))                    IIIImmmmpppprrrreeeessssssssaaaarrrriiiioooo                     iiiimmmmppppZZZZoooooooommmmRRRRoooowwww((((3333))))
  71.  
  72.  
  73.  
  74.      _m_i_n, _m_a_x       Minimum and maximum intensity values to be used for
  75.                     clamping of the zoomed image data. Using certain filters
  76.                     (e.g. Mitchell) it is possible for the zoomed data
  77.                     intensity range to exceed the original data intensity
  78.                     range. Typically these parameters are set to the minimum
  79.                     and maximum possible input data intensities. For example,
  80.                     for 8-bit input data _m_i_n would be set to 0 and _m_a_x would
  81.                     be set to 255.
  82.  
  83.      _r_e_a_d_R_o_w_F_u_n_c    Pointer to a function that will be called to read a row
  84.                     from the source image. The prototype for this function is:
  85.  
  86.                     int (*IMPReadRowFunc)(short *buffer,
  87.                                           ushort_t row,
  88.                                           void *clientData);
  89.  
  90.                     The function should read the image row indicated by _r_o_w
  91.                     and place the data in _b_u_f_f_e_r. The storage for _b_u_f_f_e_r is
  92.                     allocated and deallocated by the zoom operator and should
  93.                     not be manipulated by the read row function. _c_l_i_e_n_t_D_a_t_a is
  94.                     a pointer to caller specific information. The caller may
  95.                     specify a pointer to client data when calling the
  96.                     _i_m_p_Z_o_o_m_R_o_w function. That pointer is passed to the read
  97.                     row function.  At the caller's discretion this pointer may
  98.                     be set to NNNNUUUULLLLLLLL. A common use of the client data is to pass
  99.                     a pointer to a structure containing the image structure
  100.                     pointer and the channel number. The read row function must
  101.                     return -1 if it encountered an error while obtaining the
  102.                     row data and must return a value of 0 or greater if the
  103.                     function succeeds.
  104.  
  105.      _n_u_m_C_h_a_n_n_e_l_s    Specifies the number of channels of image data that are
  106.                     packed on a single row. For example, if each row contains
  107.                     data for only a single channel, then _n_u_m_C_h_a_n_n_e_l_s should be
  108.                     specified as one. However, if each row contains RGB data
  109.                     packed together as RGBRGBRGB..., _n_u_m_C_h_a_n_n_e_l_s should be
  110.                     specified as three.
  111.  
  112.      _f_i_l_t_e_r_T_y_p_e     Specifies the type of filter to be used for resampling the
  113.                     image during zooming. The filter types available are:
  114.  
  115.  
  116.                                     FFFFiiiilllltttteeeerrrr TTTTyyyyppppeeee    CCCCaaaatttteeeeggggoooorrrryyyy
  117.                                     __________________________
  118.                                     IIIIMMMMPPPPIIIImmmmppppuuuullllsssseeee     Replicative
  119.                                     IIIIMMMMPPPPBBBBooooxxxx         Filtered
  120.                                     IIIIMMMMPPPPTTTTrrrriiiiaaaannnngggglllleeee    Filtered
  121.                                     IIIIMMMMPPPPQQQQuuuuaaaaddddrrrraaaattttiiiicccc   Filtered
  122.                                     IIIIMMMMPPPPMMMMiiiittttcccchhhheeeellllllll    Filtered
  123.                                     IIIIMMMMPPPPGGGGaaaauuuussssssssiiiiaaaannnn    Filtered
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. iiiimmmmppppZZZZoooooooommmmRRRRoooowwww((((3333))))                    IIIImmmmpppprrrreeeessssssssaaaarrrriiiioooo                     iiiimmmmppppZZZZoooooooommmmRRRRoooowwww((((3333))))
  137.  
  138.  
  139.  
  140.                     Refer to the section entitled _F_i_l_t_e_r _F_u_n_c_t_i_o_n_s below for
  141.                     detailed information on the available filters.
  142.  
  143.      _b_l_u_r_F_a_c_t_o_r     Specifies a multiplier for the width of the filter. The
  144.                     default blur factor is 1.0. Higher factors increase the
  145.                     amount of blur present in the image.
  146.  
  147.      The _i_m_p_Z_o_o_m_R_o_w function has the following parameters:
  148.  
  149.      _z_o_o_m           Pointer to a zoom operator structure obtained from a call
  150.                     to _i_m_p_C_r_e_a_t_e_Z_o_o_m.
  151.  
  152.      _b_u_f_f_e_r         Caller allocated buffer that will be filled with the
  153.                     zoomed image row data.  The buffer should be allocated to
  154.                     accomodated _d_s_t_X_S_i_z_e * _n_u_m_C_h_a_n_n_e_l_s * _s_i_z_e_o_f(_s_h_o_r_t) bytes.
  155.  
  156.      _r_o_w            The desired zoomed row. Rows are numbered from 0 through
  157.                     _d_s_t_Y_S_i_z_e - _1.
  158.  
  159.      _c_l_i_e_n_t_D_a_t_a     Pointer to client data. This pointer is passed to the
  160.                     _r_e_a_d_R_o_w_F_u_n_c. A typical use of this is for passing a
  161.                     pointer to a structure containing the _I_M_P_I_m_a_g_e pointer and
  162.                     the channel number.
  163.  
  164.    FFFFIIIILLLLTTTTEEEERRRR FFFFUUUUNNNNCCCCTTTTIIIIOOOONNNNSSSS
  165.      The resampling filters available for zooming are summarized below. Note
  166.      that the span of the filter (i.e. x range) is expressed in terms of the
  167.      original image not the zoomed image.
  168.  
  169.           FFFFiiiilllltttteeeerrrr TTTTyyyyppppeeee    FFFFuuuunnnnccccttttiiiioooonnnn                              SSSSppppaaaannnn
  170.           _______________________________________________________________
  171.  
  172.           IIIIMMMMPPPPIIIImmmmppppuuuullllsssseeee     Not Applicable
  173.  
  174.           IIIIMMMMPPPPBBBBooooxxxx         f(x) = 0.0                          x < -0.5
  175.                          f(x) = 1.0                      -0.5 <= x < 0.5
  176.                          f(x) = 0.0                          x >= 0.5
  177.  
  178.           IIIIMMMMPPPPTTTTrrrriiiiaaaannnngggglllleeee    f(x) = 0.0                          x < -1.0
  179.                          f(x) = 1.0+x                    -1.0 <= x < 0.0
  180.                          f(x) = 1.0-x                     0.0 <= x < 1.0
  181.                          f(x) = 0.0                          x >= 1.0
  182.  
  183.           IIIIMMMMPPPPQQQQuuuuaaaaddddrrrraaaattttiiiicccc   f(x) = 0.0                          x < -1.5
  184.                          f(x) = 0.5*(x+1.5)^2            -1.5 <= x < -0.5
  185.                          f(x) = 0.75-x^2                 -0.5 <= x < 0.5
  186.                          f(x) = 0.5*(x-1.5)^2             0.5 <= x < 1.5
  187.                          f(x) = 0.0                          x >= 1.5
  188.  
  189.           IIIIMMMMPPPPMMMMiiiittttcccchhhheeeellllllll    b = 1.0/3.0
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. iiiimmmmppppZZZZoooooooommmmRRRRoooowwww((((3333))))                    IIIImmmmpppprrrreeeessssssssaaaarrrriiiioooo                     iiiimmmmppppZZZZoooooooommmmRRRRoooowwww((((3333))))
  203.  
  204.  
  205.  
  206.                          c = 1.0/3.0
  207.  
  208.                          p0 = (6.0-2.0*b)/6.0
  209.                          p2 = (-18.0+12.0*b+6.0*c)/6.0
  210.                          p3 = (12.0-9.0*b-6.0*c)/6.0
  211.                          q0 = (8.0*b+24.0*c)/6.0
  212.                          q1 = (-12.0*b-48.0*c)/6.0
  213.                          q2 = (6.0*b+30.0*c)/6.0
  214.                          q3 = (-b-6.0*c)/6.0
  215.  
  216.                          f(x) = 0.0                          x < -2.0
  217.                          f(x) = q0-x*(q1-x*(q2-x*q3))    -2.0 <= x < -1.0
  218.                          f(x) = p0+x*x*(p2-x*p3)         -1.0 <= x < 0.0
  219.                          f(x) = p0+x*x*(p2+x*p3)          0.0 <= x < 1.0
  220.                          f(x) = q0+x*(q1+x*(q2+x*q3))     1.0 <= x < 2.0
  221.                          f(x) = 0.0                          x >= 2.0
  222.  
  223.           IIIIMMMMPPPPGGGGaaaauuuussssssssiiiiaaaannnn    a(x) = 1.0/exp((1.5*x)^2)
  224.                          b(x) = 1.0/exp(1.5^4)
  225.                          f(x) = a(x)-b(x)
  226.  
  227. RRRREEEETTTTUUUURRRRNNNN VVVVAAAALLLLUUUUEEEE
  228.      _i_m_p_C_r_e_a_t_e_Z_o_o_m returns a pointer to a zoom operator structure if execution
  229.      was successful. NNNNUUUULLLLLLLL is returned and _I_M_P_e_r_r_n_o is set if an execution
  230.      error has occurred.
  231.  
  232.      _i_m_p_Z_o_o_m_R_o_w returns 0 if execution was successful. -1 is returned and
  233.      _I_M_P_e_r_r_n_o is set if an execution error occurred.
  234.  
  235. EEEEXXXXEEEECCCCUUUUTTTTIIIIOOOONNNN EEEERRRRRRRROOOORRRR CCCCOOOODDDDEEEESSSS
  236.      In addition to the system error codes defined in _e_r_r_n_o._h, the following
  237.      _l_i_b_i_m_p specific error codes may be returned.
  238.  
  239.      _i_m_p_C_r_e_a_t_e_Z_o_o_m will fail under the following circumstances.
  240.  
  241.      IMP_ERR_MEMALLOC         Dynamic memory allocation failed. This indicates
  242.                               an out-of-memory condition.
  243.  
  244.      _i_m_p_Z_o_o_m_R_o_w will fail under the following circumstances.
  245.  
  246.      IMP_ERR_READROW          Read row function failed.
  247.  
  248. NNNNOOOOTTTTEEEESSSS
  249.      1.   The storage for the _I_M_P_Z_o_o_m structure is allocated by the zoom
  250.           operator creation function. This storage is deallocated by the
  251.           _i_m_p_D_e_s_t_r_o_y_Z_o_o_m function.  The caller should not explicitly
  252.           reallocate or deallocate any storage related to the image structure.
  253.  
  254.      2.   The fields of the _I_M_P_Z_o_o_m structure are private and should not be
  255.           modified by the caller.
  256.  
  257.  
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. iiiimmmmppppZZZZoooooooommmmRRRRoooowwww((((3333))))                    IIIImmmmpppprrrreeeessssssssaaaarrrriiiioooo                     iiiimmmmppppZZZZoooooooommmmRRRRoooowwww((((3333))))
  269.  
  270.  
  271.  
  272. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  273.      libimp(3)
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.                                                                         PPPPaaaaggggeeee 5555
  328.  
  329.  
  330.  
  331.